﻿using UnityEngine;
using System.Collections;
using Dict.DataModel;
using ProtoBuf.Message;

namespace Room
{
    public class RCUIMine : RCUIBase
    {
        protected TableFieldResourcePos minePos;
        protected TableFieldResource mine;
        public RCUIMine(RoomCharactor owner)
            : base(owner)
        {
            this.owner = owner;
            type = UIType.Mine;
            ClickRange = 1.5f;
        }

        public virtual void Init(TableFieldResource mine, TableFieldResourcePos minePos)
        {
            this.mine = mine;
            this.minePos = minePos;
            InitButton(delegate() 
            {
                var room = RoomManager.currentRoom as RoomField;
                var self = room.charactorManager.GetSelfCharactor().ai as RCAISelf;
               
                self.AutoGoto(owner.transform.position, () => 
                {
                    //var ai = room.charactorManager.GetSelfCharactor().ai as RCAIActor;
                    if (room != null)
                    {
                        var netManager = room.netManager as RoomNetField;
                        netManager.SendGetFieldRes(mine.id, minePos.posId);
                    }
                });
            });
            SetButtonSprite("UI_yewai_biaoshi_wakuang");
        }

        protected override void OnClick()
        {
            /*
            var room = RoomManager.currentRoom as RoomField;
            var ai = room.charactorManager.GetSelfCharactor().ai as RCAIActor;
            if (room != null)
            {
                room.netManager.SendGetFieldRes(mine.id, minePos.posId);
            }
            */
        }

    }
}
